<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link type="text/css" rel="stylesheet" href="main2.css">
    <title>海事行政许可受理通知书</title>
	<!--jquery -->
	<script type="text/javascript" src="../js/jquery/jquery-2.0.3.min.js" ></script>
	
	<script type="text/javascript" src="../js/share.js"></script>
	<script type="text/javascript">

	var itemno = "";
	var applyid = "";
	var nodeno = "";
	var orgcode = "";
	var nextnodecode1 = "";
	var selectID = "userlist";
	var applyno = "";

	$(function(){
		applyno = getUrlParam("applyno");
		bindApply(applyno);
	})


	function bindApply(applyno){
		$.ajax({ 
			url: basePath() + 'business/getapplyinfo.do',
			data: {"applyno": applyno},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonApply = data.datas;
//		    		var jsonBusiness = data.datas.business;
//		    		var jsonMaterial = data.datas.material;
		    		
		    		bindApplyForm(jsonApply);
		    		
		    		//绑定业务资料
		    		bindBusinessForm(jsonApply['applyid'], jsonApply['itemno']);
//		    		
//		    		//绑定附件材料
					bindMaterialListForm(jsonApply['applyid']);

// 					绑定受理数据
					bindAcceptForm(jsonApply['applyid']);
		    	}
	      	}
		});
	}

	function bindApplyForm(jsonApply){
		$('#proposer').html(jsonApply['proposer']);
		
		for(var d in jsonApply){//遍历json对象的每个key/value对,p为key
			if(d == 'applytime'){
				$('#' + d).html(formatDate(jsonApply[d], 'yyyy年mm月dd日'));
			}
			else if(d == 'nodename'){
				if(jsonApply[d] == '办结')
					$('#' + d).html('<span style="color:green;font-weight: bold;">' + jsonApply[d] + '</span>');
				else if(jsonApply[d].indexOf('补正') >= 0){
					$('#' + d).html('<span style="color:red;font-weight: bold;">' + jsonApply[d] + '</span>');
					$('#correction').show();
					$('#correction').attr('href', 'correction.html?applyno=' + applyno);
				}
				else if(jsonApply[d].indexOf('申报') >= 0){
					$('#' + d).html('<span style="color:red;font-weight: bold;">未提交</span>');
					$('#edit').show();
					$('#edit').attr('href', 'edit.html?applyno=' + applyno);
				}
	        	else if(jsonApply[d].indexOf('受理') >= 0)
	        		$('#' + d).html('<span style="color:blue; font-weight: bold;">待受理</span>');
				else{
					$('#' + d).html('<span style="color:blue;font-weight: bold;">已受理</span>');
				}
			}
			else{
				$('#' + d).html(jsonApply[d] == '' ? '/' : jsonApply[d]);
			}
		}
	}

	function bindBusinessForm(applyid, itemno){

		$.ajax({ 
			url: basePath() + 'business/getbusinessinfo.do',
			data: {"applyid": applyid, "itemno": itemno},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonBusiness = data.datas;

		    		for(var d in jsonBusiness){//遍历json对象的每个key/value对,p为key
		    			if(d == 'workbegintime' || d == 'workendtime'){
		    				$('#' + d).html(formatDate(jsonBusiness[d], 'yyyy-mm-dd'));
		    			}
		    			else{
		    				$('#' + d).html(jsonBusiness[d] == '' ? '/' : jsonBusiness[d]);
		    			}
		    		}
		    	}
	      	}
		});
	}

	function bindMaterialListForm(applyid){

		$.ajax({ 
			url: basePath() + 'business/getmaterialinfo.do',
			data: {"applyid": applyid},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonMaterial = data.datas;

		    		var jaMaterial = [];
		    		for(var n = 0; n < jsonMaterial.length; n++){
		    			if(jsonMaterial[n]['fileid'] != undefined && '' != jsonMaterial[n]['fileid']){
			    			jaMaterial.push(jsonMaterial[n]);
	    				}
		    		}
		    		

		    		var k = 1;
		    		var minCount = 10;

		    		if(minCount < jaMaterial.length)
		    			minCount = jaMaterial.length;
		    		
		    		for(var i = 0; i < minCount; i++, k++){
		    			

		    			var quantity = "";
		    			var materialname = "";
		    			var opinion = "";
	    				var fileid = "";
	    				
		    			
		    			if(i < jaMaterial.length){
		    		//		var ismustsubmit = jsonMaterial[i]['ismustsubmit'];
		    		//		var ismustsubmitStr = "";
		    		//		var must = false;
		    		//		if(ismustsubmit == 1){
		    		//			ismustsubmitStr = '<span style="color:red;">*</span>';
		    		//			must = true;
		    		//		}
		    		//		var index = jsonMaterial[i]['serialnumber'];
		    				quantity = jaMaterial[i]['quantity'];
		    				materialname = jaMaterial[i]['materialname'];
		    				

		    				if(jaMaterial[i]['fileid'] != undefined && '' != jaMaterial[i]['fileid']){
		    					fileid = jaMaterial[i]['fileid'];
		    				}
		    				
		    				
		    		//		var fileurl = jsonMaterial[i]['fileurl'];
		    			}

	    				if("" != fileid){
			    			var trStr = '<tr>'+
			    					    '    <td class="td-1">'+k+'</td>'+
			    					    '    <td class="td-2" style="text-align:left;">'+materialname+'</td>'+
			    					    '    <td class="td-1">'+quantity+'</td>';
			    					    if(i == 0)
			    					    	trStr += '	 <td class="td-1" rowspan="'+ minCount +'" id="opinion"></td>';
			    					    
			    				    	trStr += '</tr>';
			    			
			    			$('#material').find('tbody').append(trStr);
	    				}
	    				else{
			    			var trStr = '<tr>'+
    					    '    <td class="td-1">'+k+'</td>'+
    					    '    <td class="td-2"></td>'+
    					    '    <td class="td-1"></td>';
    					    if(i == 0)
    					    	trStr += '	 <td class="td-1" rowspan="'+ minCount +'"></td>';
    					    
    				    	trStr += '</tr>';
    			
    						$('#material').find('tbody').append(trStr);
	    				}
		    		}
		    	}
	      	}
		});
	}
	
	function bindAcceptForm(applyid){

		$.ajax({ 
			url: basePath() + 'business/getacceptinfo.do',
			data: {"applyid": applyid},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonAccept = data.datas;
		    		
					for(var d in jsonAccept){//遍历json对象的每个key/value对,p为key

		    			if(d == 'audittime'){
		    				$('#' + d).html(formatDate(jsonAccept[d], 'yyyy年mm月dd日'));
		    			}
		    			else{
		    				$('#' + d).html(jsonAccept[d] == '' ? '/' : jsonAccept[d]);
		    			}
		    		}
		    	}
	      	}
		});
	}
	</script>
</head>
<body>
<div class="image">
    <img src="image/msa.gif" style="float: left">
</div>
<h1 >海事行政许可受理通知书</h1>
<div class="编号" style="text-align: right;">
    <p style="display: inline; font-size:14px;">编号：</p>
    <p style="display:inline;text-decoration: underline;font-size: 14px;">
		<span id="applyno" style="font-size: 16px;"></span>
	</p>
</div>
<div class="正文">
    <p style="text-decoration: underline;display:inline;"><br>
		<span id="company"></span>
	</p>
    <p style="display:inline;">:</p>
    <p style="display:inline;padding-left: 40px"><br>你（船/单位）于</p>
		<span id="applytime" style="text-decoration: underline; font-size: 18px;"></span>
    <p style="display:inline;">，提交的关于</p>
    <p style="display:inline;">
			<span id="itemname" style="text-decoration: underline;"></span>
	</p>
    <p style="display:inline;">的海事行政许可申请，经审查符合受理规定，现予以受理，并收存以下材料。本机构将自即日起</p>
    <p style="display:inline;">
		<span id="days" style="text-decoration: underline;"></span>
	</p>
    <p style="display:inline;">工作日内依法做出决定。</p>
</div>
<div class="印章">
    <p style="display: inline;padding-left: 550px;font-size:14px;"></p>
    <span id="audittime"></span>（印章）
</div>
<div class="表格">
<table id="material" border="1"  align="center" cellspacing="0" cellpadding="0" style="border-style: solid;border-width: 1px;border-color: black;border-collapse: collapse;">
    <caption style="font-weight: bold;height: 30px;font-size: 18px">申报材料清单</caption>
    <thead>
    <tr>
        <td class="td-1" style="font-weight: bold">序号</td>
        <td class="td-2" style="font-weight: bold">材料名称</td>
        <td class="td-1" style="font-weight: bold">份数</td>
        <td class="td-3" style="font-weight: bold">备注</td>
    </tr>
    </thead>
    <tbody>
    </tbody>
</table>
    <p style="font-size: 16px">申请人确认以上材料与提交的一致。</p>
</div>
<div class="申请人">
    <p style="display: inline;padding-left: 550px;">申请人签字:</p>
    <p style="display:inline;text-decoration: underline;"></p>
    <p style="display:inline;padding-left: 550px;"><br>日期：</p>
    <p style="display:inline;text-decoration: underline;"></p>
    <p style="display:inline;">&nbsp;年</p>
    <p style="display:inline;text-decoration: underline;"></p>
    <p style="display:inline;">&nbsp;月</p>
    <p style="display:inline;text-decoration: underline;"></p>
    <p style="display:inline;">&nbsp;日</p>
</div>
<p style="font-size: 10px;padding-left: 20px">注：不适用者划去，领取决定书时请出示本通知书和领取人身份证明</p>
</body>
</html>